const Koa = require("koa");
const Router = require("koa-router");

const signature = require('./signature');

const createSignature = signature.getSignature({appId: 'wx36cd719df8a35fdd',appSecret: '70d058f2427c6bb2b9e812f4b5c7a37f',appToken: 'lj316641206'});

const app = new Koa();
const router = new Router();

router.get("/", async(ctx, next) => {
    ctx.body = await asign("https://wxpay.jkfeel.com");
});

const asign = function(url){
    return new Promise((resolve, reject) => {
        createSignature(url,function(error, result){
            if(error){
                reject(error);
            } else {
                resolve(result)
            }
        });
    })
}

app.use(router.routes());
app.listen(3000);